package cn.school.sys.vo.export.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class EnableConvert implements Converter<String> {
    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String enbaleDesc = "0";
        if ("启用".equals(cellData.getStringValue())) {
            enbaleDesc = "1";
        }
        return enbaleDesc;
    }

    @Override
    public CellData convertToExcelData(String s, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String enbaleDesc = "禁用";
        if ("1".equals(s)) {
            enbaleDesc = "启用";
        }
        return new CellData(enbaleDesc);
    }
}
